#ifndef bodyShape_h
#define bodyShape_h

#include<stdio.h>
#include<math.h>
#include<GL/glut.h> 
#include<time.h>

#define NUM_OF_DEGREES 13  // number of angle paramters of the arms and juncturas to load from file and saving it

#define ERROR 0 // an ERROR flag


typedef struct point3d {
	float x;
	float y;
	float z;
} Point,*pPoint;  // the struct of a point in 3D

typedef struct bodyshape 
{
	float bodyX; // the whole spider's body around the X axis
	float bodyY; // the whole spider's body around the Y axis
	Point bodyC; // the color of the body
	Point JuncturaC; // the color of the arms and juncturas
	Point MainJuncturaC; // the color of the main juncturas

	int UpperRightDegree; // the angle of the upper right arm around Z axis
	int UpperRightYDegree;  // the angle of the upper right arm around Y axis
	int UpperRightExtensionDegree;  // the angle of the upper right extension junctura arm around Y&Z axis
	int UpperRightE2Degree; // the angle of the 2nd upper right extension junctura arm around Y axis
	
	int UpperLeftDegree; // the angle of the upper left arm around Z axis
    int UpperLeftYDegree; // the angle of the upper left arm around Y axis
	int UpperLeftExtensionDegree; // the angle of the upper left extension junctura arm around Y&Z axis

	int LowerRightDegree; // the angle of the lower right arm around Z axis
	int LowerRightYDegree; // the angle of the lower right arm around Y axis
	int LowerRightExtensionDegree; // the angle of the lower right extension junctura arm around Y&Z axis
	
	int LowerLeftDegree; // the angle of the lower left arm around Z axis
    int LowerLeftYDegree; // the angle of the lower left arm around Y axis
	int LowerLeftExtensionDegree; // the angle of the lower left extension junctura arm around Y&Z axis
	
	int direction; // sets the direction of the rotation. ( 1= anti-clockwise , -1 = clockwise )
} body,*pBody; // the struct of the spider's body

// functions declaration 
void	renderCallBack(); // the callback function of our rendering
void	reshape(int width, int height); // the reshape callback function
void	keyPress(int key, int x, int y); // the special keyboard function for the spider's arms movement
void    ourKBfunc(unsigned char key, int x, int y); // the keyboard function for saving the spider status and quitting the application

void initRotation(pBody arg); // the initial rotation of the spider's body around the X & Y axis to 90 degrees each
void	initBody(pBody,FILE *); // initialise the spider's body's parameters
void LoadBodyDegreesPtr(pBody a); // sets the pointers array to the spider's body structure fields so we can save the values in a file anytime
void	initP(pPoint); // initializing a point in 3D to 0,0,0
void	SetColor(Point); // sets the color according the values of a point in 3D
void	DrawP(); // draws the Junctura Main Point
void	drawBody(pBody); // the function is responsible for drawing the spiders' body , arms and juncturas
void idle(); // the spider's body animation when the application is in an idle state.


int BodyFileInit( FILE *b ); // creates the file body.txt if not exists. contains the initial spider arms and juncturas parameters
int BodyFileLoad( FILE *b , int body_array_load[] ); //load the parameters from the file body.txt into an array so we can use those parameters
int BodyFileSave(); // saving the spider's body's structure fields in the file body.txt



body arg; //our body
int *body_degrees_ptr[NUM_OF_DEGREES]; // pointer array to the spider body structure fields in order to save them in a file at any moment.
int id; // the id of the window application so we can later kill it and quit the application ( "he he he he he" (: ).
//end of specifics



#endifay_load[] ); //load the parameters from the file body.txt into an array so we can use those parameters
int BodyFileSave(); // saving the spider's body's structure fields in the file body.txt



body arg; //our body
int *body_degrees_ptr[NUM_OF_DEGREES]; // pointer array to the spider body structure fields in order to 